#include "PickPlayersDialog.h"

#include <boost/bind.hpp>
#include "../../graphic/ColoursPalette.h"
#include "../../../../utils/gui/Button.h"
#include "../../../../domain/models/CardSet.h"

using namespace Views::Helpers::Server;
using namespace Views::Helpers::Server::Gameplay;
using namespace Utils;

PickPlayersDialog::PickPlayersDialog()
	:players_count(0)
{
	Shape = sf::Shape::Rectangle(0, 0, 600., 500., Views::Helpers::Graphic::Colours::Bright);
	GUI::Label* Header = new GUI::Label(L"Oczekuje na graczy", GUI::Label::CENTER, GUI::Label::MIDDLE);
	Header->SetTextWidth(600);
	Header->SetTextHeight(30);

	OkButton = new GUI::Button();
	OkButton->SetShape(sf::Shape::Rectangle(0, 0, 60, 30, Views::Helpers::Graphic::Colours::LightAlt));
	GUI::Label* Text = new GUI::Label(L"Ok", GUI::Label::CENTER, GUI::Label::MIDDLE);
	Text->SetTextWidth(OkButton->GetWidth());
	Text->SetTextHeight(OkButton->GetHeight());

	OkButton->SetText(*Text);
	OkButton->Move(this->GetWidth() - OkButton->GetWidth() - 10, this->GetHeight() - OkButton->GetHeight() - 10);

	addChild(OkButton);
	addChild(Header);
}

void PickPlayersDialog::addPlayer(Cards::PlayerCard* card)
{
	players_count++;
	GUI::Button* Player = new GUI::Button();
	Player->SetShape(sf::Shape::Rectangle(0, 0, 560., 40., Views::Helpers::Graphic::Colours::Light));
	GUI::Label* Name = new GUI::Label(card->getTitle(), GUI::Label::CENTER, GUI::Label::MIDDLE);
	Name->SetTextWidth(Player->GetWidth());
	Name->SetTextHeight(Player->GetHeight());
	Player->addChild(Name);
	Player->Move(this->GetRect().Left + 20, 40 + players_count * (Player->GetHeight() + 10));
	addChild(Player);
}

